<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@include file="/taglibs.jsp"%>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">  
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="${ctx}/resources/semanticui/semantic.min.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/resources/apps.css" rel="stylesheet" type="text/css" />
    <title>上传候选人简历</title>  
</head>
<body>
<div class="ui segment" id="n-page">
&nbsp;<br>
&nbsp;<br>
<h3 class="ui attached header" id="list-title">
    上传简历
</h3>
&nbsp;<br>
&nbsp;<br>
<input type="hidden" name="recommendid" id="recommendid" value="${recommendid}" />

<div class="ui segment">

感谢您将候选人${ personName }推荐给职位${jobName}。&nbsp;<br>&nbsp;<br>
公司HR在确认需要面试该候选人时，会发“面试邀请”。&nbsp;<br>&nbsp;<br>
如果您推荐的候选人被正式录用，您将得到相应的奖金。&nbsp;<br>&nbsp;<br>

我们建议您上传候选人的简历，便于职位发布公司对候选人的深入了解。<br><br>
点击下面的“上传简历”按钮，将候选人的简历以照片形式提交给我们。
</div>

</div>


<c:choose>
	<c:when test="${recommend.resid != null }">
		<img class=" floated  ui image" id="img" src="${ctx}/rs/${recommend.resid}.jpg">
	</c:when> 
	<c:otherwise>
		<img class=" floated  ui image" id="img"  src="">
	</c:otherwise>
</c:choose>

<div class="ui segment" id="btn-next">
    <div class="fluid ui button" id="next">上传简历</div>
</div>

<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="${ctx}/resources/semanticui/jquery-2.1.4.min.js"></script>
<script src="${ctx}/resources/semanticui/semantic.js" type="text/javascript"></script>
<script type="text/javascript">

wx.config({
    debug: false, 
    appId: "${config.appid}",  
    timestamp: ${config.currenttimestamp},  
    nonceStr: "${config.nonceStr}", 
    signature: "${config.signatureStr}", 
    jsApiList: ['checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage',
        'onMenuShareQQ',
        'onMenuShareWeibo',
        'chooseImage',
        'previewImage',
        'uploadImage',
        'downloadImage']  
});

    var url = '${ctx}/wechat/headhunter/uploadResume.do';
    var handler = { 
        activate: function() { 
            $(this).addClass('active').siblings().removeClass('active'); 

            if($(this).attr('id') == 'next') {
                wx.chooseImage({
                    count: 1,
                    success: function (res) {
                        var localId = res.localIds[0];
                        wx.uploadImage({ 
                            localId: localId,  
                            isShowProgressTips: 1,  
                            success: function (res) { 
                                var serverId = res.serverId;
                                var recommendid = $('#recommendid').val();
                                resid=res.serverId;
                                $("#img").attr("src",serverId);
                                wx.downloadImage({
                                    serverId: res.serverId, // 需要下载的图片的服务器端ID，由uploadImage接口获得
                                    isShowProgressTips: 1, // 默认为1，显示进度提示
                                    success: function (res) {
                                        var localId = res.localId; // 返回图片下载后的本地ID
                                        //获取本地图片接口
                                        wx.getLocalImgData({
                                            localId: localId, // 图片的localID
                                            success: function (res) {
                                                var localData = res.localData; // localData是图片的base64数据，可以用img标签显示
                                            }
                                        });
                                    }
                                });
                                url += "?recommendid=" + recommendid;
                                url += "&resid=" + serverId;
                                location.href = url;
                            } 
                        });
                        
                    }
                });
            }
        } 
    };

    var resid;
    $(document).ready(function() { 
        
        wx.ready(function(){
            $('.button').on('click', handler.activate);
        });

    });

</script>
</body>
</html>